<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb" xmlns:xu="http://www.xmldb.org/xupdate">

	<p:param type="input" name="data"/>
	<p:param type="output" name="data"/>

	<p:choose href="#data">
		<p:when test="/lang !='en'">

			<p:processor name="oxf:xslt">
				<p:input name="data" href="#data"/>
				<p:output name="data" id="file"/>
				<p:input name="config">
					<config xsl:version="2.0">
						<url>/locales/<xsl:value-of select="/lang"/>/messages.po</url>
						<content-type>text/plain</content-type>
						<encoding>utf-8</encoding>
					</config>
				</p:input>
			</p:processor>

			<p:processor name="oxf:url-generator">
				<p:input name="config" href="#file"/>
				<p:output name="data" id="messages"/>
			</p:processor>
		</p:when>
		<p:otherwise>
			<p:processor name="oxf:identity">
				<p:input name="data">
					<document/>
				</p:input>
				<p:output name="data" id="messages"/>
			</p:processor>
		</p:otherwise>
	</p:choose>
	<p:processor name="oxf:unsafe-xslt">
		<p:input name="data" href="#messages"/>
		<p:input name="lang" href="#data"/>
		<p:input name="config">
			<translation xsl:version="2.0" lang="{doc('input:lang')/lang}">
				<xsl:variable name="unparsedArray" select="tokenize(/document/text(), 'msgid')"/>
				<xsl:for-each select="$unparsedArray">
					<xsl:if test="position() != 1">
						<message>
							<xsl:attribute name="id">
								<xsl:value-of select="replace(normalize-space(substring-before(., 'msgstr')), '&#34;', '')"/>
							</xsl:attribute>
							<xsl:value-of select="replace(normalize-space(substring-after(., 'msgstr')), '&#34;', '')"/>
						</message>
					</xsl:if>
				</xsl:for-each>
			</translation>
		</p:input>
		<p:output name="data" ref="data"/>
	</p:processor>
</p:config>